package com.forum.mapper;

import com.forum.annotation.AutoFill;
import com.forum.dto.UserDTO;
import com.forum.dto.UserPageQueryDTO;
import com.forum.entity.User;
import com.forum.entity.UserInfo;
import com.forum.enumeration.OperationType;
import com.forum.vo.UserInfoVO;
import com.github.pagehelper.Page;
import org.apache.ibatis.annotations.*;

import java.util.List;
import java.util.Map;

@Mapper
public interface UserMapper {


   /* @Insert("insert into user(username,password,create_time,update_time)" +
            "values " +
            "(#{username},#{password},#{createTime},#{updateTime})")*/
    @AutoFill(OperationType.INSERT)
    void creatUser(UserDTO userDTO);

    @Select("select * from user where username = #{username}")
    User queryUserByUserName(String username);

    @Insert("insert into user_info(user_id,status,sex)values (#{userId},#{status},#{sex})")
    void insertStatus(UserInfo userInfo);



    Page<User> pageQuery(UserPageQueryDTO userPageQueryDTO);

    @Update("update user_info set status = #{status} where user_id = #{id}")
    void updateByIdStatus(Long id, Integer status);

    void updateById(User user);

    void deleteByIds(List<Long> ids);

    Long queryByIds(List<Long> ids);

    Long sumByMap(Map map);

    Long sexRatio(int i);

    UserInfoVO getUserInfoById(Long id);

    @Update("update user_info set background_image = #{backgroundUrl} where user_id = #{id}")
    void updateByIdBackground(Long id, String backgroundUrl);
    @Select("select background_image from user_info where user_id = #{id}")
    String getbackgroundUrl(Long id);

}
